/***
** Author: MD.POLASH ISLAM (PRINCE)
***/
#include<bits/stdc++.h>
using namespace std;
//constants :
const int N = (int) 1e6+5;
const int M = (int) 1e9+5;
const int mod = (int) 1000000007;
const int max_prime = (int) 1e6+3;
const int BLK = (int) 700;
const double pi = acos(-1.0);
#define ll long long int
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define vll vector<ll>
#define vvll vector<vll>
#define vcc vector<char>
#define endl "\n"
#define vbb vector<bool>
#define all_0(x) memset(x,0,sizeof(x))
#define all_neg(x) memset(x,-1,sizeof(x))
#define all_1(x) memset(x,1,sizeof(x))
#define for0(n) for (int i = 0; i < (int)(n); ++i)
#define in_range(i,x,y) for(int i=x;i<=y;i++)
#define in_range_back(i,x,y) for(int i=y;i>=x;i--)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define vll vector<ll>
#define yes "YES"
#define no "NO"
int divs[N+10];
int ans[N+10];
bool cmp(pair<int,int>a,pair<int,int> b)
{
if (a.second!=b.second)
{
return a.second>b.second;
}
else
{
return a.second<b.second;
}
}
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
int removeZeros(int num)
{
int ret = 0;
int ten = 1;
while (num)
{
int dig = num % 10;
num /= 10;
if (dig)
{
ret += dig * ten;
ten *= 10;
}
}
return ret;
}
void divcount()
{
for (int i=1; i<=N; i++)
{
for (int j=i; j<=N; j+=i)
{
divs[j]++;
}
}
}
ll bigmod()
{
ll ans=1;
ll a=6;
ll n=mod-2;
ll md=mod;
while (n)
{
if (n%2)
{
ans=(ans*a)%md;
n--;
}
else
{
a=(a*a)%md;
n=n/2;
}
}
return ans;
}
int countoftwo(int ans){
int cnt=0;
while ( ans>0)
{
ans=ans/2;
cnt++;
}
return cnt;
}
bool contains(string s, string target) {
for (int i = 0; i < s.size(); i++) {
if (i + target.size() <= s.size() && s.substr(i, target.size()) == target) {
return true;
}
}
return false;
}
string rearrange(string s) {
string selise = "SELISE";
string selise_dp = "SELISE Digital Platforms";
sort(s.begin(), s.end());
if (contains(s, selise_dp)) {
return "BOTH";
} else if (contains(s, selise)) {
return "SELISE";
}
return "NONE";
}
/* void print(__int128 x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9) print(x / 10);
putchar(x % 10 + '0');
}
__int128 read() {
__int128 x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}*/
// starting -->>
bool isprime(int n) {
if (n < 2) {
return false;
}
int sqrt_n = sqrt(n);
for (int i = 2; i <= sqrt_n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
bool checkPowerOfTwo(ll num){
return (num!=0 && ((num & (num - 1)) == 0));
}
ll sqrta(ll n) {
ll left = 0, right = sqrt(n) + 1;
while (left < right) {
ll mid = (left + right + 1) / 2;
if (mid * mid <= n) {
left = mid;
} else {
right = mid - 1;
}
}
return left;
}
string checkFactors(int n, int m) {
for (int i = 1; i <= m; i++) {
if (n % i == 0 && n/i <= m) {
return "NO";
}
}
}
void solve()
{
int n;
cin >> n;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int ans = -1;
for (int k = 0; k <= n; k++) {
int truth = 0, lie = 0;
for (int i = 1; i <= n; i++) {
if (k >= a[i]) {
truth++;
}
else {
lie++;
}
}
if (lie == k) {
ans = k;
break;
}
}
cout << ans << '\n';
}
int main()
{
ios_base :: sync_with_stdio (false);
cin.tie(NULL);
//solve2();
int t,k=1;
cin>>t;
while (t--)
{ // cout<<"Case "<<k++<<": ";
solve();
}
//solve();
return 0;
}
454A - Little Pony and Crystal Mine | 2A - Winner |
1622B - Berland Music | 1139B - Chocolates |
1371A - Magical Sticks | 1253A - Single Push |
706B - Interesting drink | 1265A - Beautiful String |
214A - System of Equations | 287A - IQ Test |
1108A - Two distinct points | 1064A - Make a triangle |
1245C - Constanze's Machine | 1005A - Tanya and Stairways |
1663F - In Every Generation | 1108B - Divisors of Two Integers |
1175A - From Hero to Zero | 1141A - Game 23 |
1401B - Ternary Sequence | 598A - Tricky Sum |
519A - A and B and Chess | 725B - Food on the Plane |
154B - Colliders | 127B - Canvas Frames |
107B - Basketball Team | 245A - System Administrator |
698A - Vacations | 1216B - Shooting |
368B - Sereja and Suffixes | 1665C - Tree Infection |